<!--
 * @Author: kongfanrong
 * @Date: 2022-04-17 11:17:10
 * @LastEditors: kongfanrong
 * @LastEditTime: 2022-05-05 18:09:44
 * @Description: file content
-->
<template>
  <div class="template">
    <hunk-head icon="home" name="合同详情"></hunk-head>
    <div @click="readContract" >
      点击阅读合同
          <!-- <web-view style="height: 200px;" :src="pdfPath" v-if="pdfPath"></web-view> -->
    </div>
  
    <button open-type="share" :class="{'btn-round':true}" @click="bindSign">发送</button>
  </div>
</template>

<script>
import Head from '@componentsMine/head'
import { tEContractInfo } from "@/apis/contract"
import {debounce} from 'lodash'
export default {
  components: {
    'hunk-head': Head
  },
  data() {
    return {
      pdfPath:'',
      eid:'',
      isRead:false
    }
  },
  computed:{
    userInfo() {
    }
  },
   onShareAppMessage(res) {
    if (res.from === 'button') {
      console.log('点击分享',res.target)
    }
    return {
      title: '电子合同',
      path: '/pages/contractDetail/index?eid='+this.eid
    }
  },
  onLoad(el){
      this.eid = el.eid
  },
  created(){
  },
  methods: {
    readContract:debounce(function(){
        uni.showLoading({
          title: '加载中...'
      })
      tEContractInfo({
        eid:this.eid
      }).then(e=>{
        uni.downloadFile({
          url: e.data.fileurl,
          success:(res)=> {
            var filePath = res.tempFilePath;
            this.pdfPath = filePath
            uni.openDocument({
              filePath: filePath,
              showMenu: true,
              success:(res) =>{
                    uni.hideLoading()
                this.isRead = true
                console.log('打开文档成功');
              }
            });
          }
        });
      })
    },1000),
      radioChange(){
        this.isAgree = !this.isAgree 
      },
      bindSign(){
       
      }
  }
}
</script>

<style lang="scss" scoped>
.template {
  @include num();
  background: #F9F9F9;
  display: flex;
  flex-direction: column;
  .pdf{
      height:450px;
  }
  .btn-round.inactive{
    background: #ccc;
    box-shadow: none;
  }
  .btn-round {
    width: 345px;
    height: 45px;
    font-size: 16px;
    text-align: center;
    line-height: 45px;
    margin: 0 auto;
    color: #fff;
    background: linear-gradient(315deg, #FFAA58 0%, #FFBD6C 100%);
    box-shadow: 0px 2px 4px 0px rgba(252, 174, 55, 0.21), 0px 3px 5px 0px rgba(255, 216, 111, 0.14);
    border-radius: 100px;
  }
}
</style>
